package io.lkt.modules.sys.service.impl;

import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BArticleShieldDao;
import io.lkt.modules.sys.entity.BArticleShieldEntity;
import io.lkt.modules.sys.service.BArticleShieldService;


@Service("bArticleShieldService")
public class BArticleShieldServiceImpl extends ServiceImpl<BArticleShieldDao, BArticleShieldEntity> implements BArticleShieldService {
    @Autowired
    private BArticleShieldDao bArticleShieldDao;

    @Override
    @DataSource("logdb")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BArticleShieldEntity> page = this.page(
                new Query<BArticleShieldEntity>().getPage(params),
                new QueryWrapper<BArticleShieldEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @DataSource("logdb")
    public List<BArticleShieldEntity> getList(Map<String, Object> params) {
        return bArticleShieldDao.getList(params);
    }

    @Override
    @DataSource("logdb")
    public Integer getListTotal(Map<String, Object> params) {
        return bArticleShieldDao.getListTotal(params);
    }

    @Override
    @DataSource("logdb")
    public BArticleShieldEntity getByArticleId(Integer articleId) {
        return bArticleShieldDao.getByArticleId(articleId);
    }

    @Override
    @DataSource("logdb")
    public int deleteByArticleId(Integer articleId) {
        return bArticleShieldDao.deleteByArticleId(articleId);
    }

    @Override
    public int saveInfo(BArticleShieldEntity bArticleShield) {
        bArticleShield.setCreateTime(new Date());
        return bArticleShieldDao.saveInfo(bArticleShield);
    }

}
